"""
把39中有同义词的疾病先提取过来
"""
import json

for i in range(4):
    filename = 'disease' + str(i + 1) + '.json'
    res_list = []
    with open(filename, mode='r', encoding='utf-8') as f:
        json_dict = json.loads(f.read())
        for key, values in json_dict.items():
            name = values['disease_name']
            alias = values['disease_alias']
            # print(alias)
            if alias:
                res_list.append((name, alias))
    with open('alias.txt', mode='a', encoding='utf-8') as f2:
        for name, alias in res_list:
            alias = ','.join(alias)
            f2.write(f'{name} {alias}\n')
